#include "CEUtilities.h"

#include "CEMaterial.h"
#include "CEGraphicLayer.h"

#include "CESubmesh.h"

//----------------------------------------------------------------------
Submesh::~Submesh()
{
	SAFE_DELETE(m_VB);		
	SAFE_DELETE(m_IB);
	SAFE_DELETE(m_BoneAssignment);
}


//----------------------------------------------------------------------
void Submesh::Render()
{
	HRESULT r = GraphicLayer::GetSingleton()->DrawIndexedPrimitive(*m_IB);
}



//----------------------------------------------------------------------
void Submesh::RestoreDeviceObjects()
{
	if(m_VB)
	{
		m_VB->RestoreDeviceObjects();
	}
	if(m_IB)
	{
		m_IB->RestoreDeviceObjects();
	}
}


//----------------------------------------------------------------------
void Submesh::InvalidateDeviceObjects()
{
	if(m_VB)
	{
		m_VB->InvalidateDeviceObjects();
	}
	if(m_IB)
	{
		m_IB->InvalidateDeviceObjects();
	}
}


//----------------------------------------------------------------------
void Submesh::DeleteDeviceObjects()
{
	if(m_VB)
	{
		m_VB->DeleteDeviceObjects();
	}
	if(m_IB)
	{
		m_IB->DeleteDeviceObjects();
	}
}